
package obsoleto;

import conexion.conexionBD;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;

public class ListarMateriasParcial extends HttpServlet {

    Connection conn; //CONEXION COMENTADA
    public void init() {
    }

    public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {

        String idAlumno=(String)req.getParameter("idalumno");
        res.setContentType("text/html");
        PrintWriter out = res.getWriter();
        PreparedStatement stmt;
        String aux="";

        try {
            conexionBD cbd=new conexionBD();
            cbd.connect();
            conn=cbd.getConn();
        } catch (Throwable t) {
            t.printStackTrace();
        }

        try {
            stmt = conn.prepareStatement("select nombre, parcial1, parcial2 from alumnosmaterias as a inner join materias as m on a.idmateria=m.idmateria where a.idalumno=?");
            stmt.setString(1, idAlumno);
            ResultSet rs=stmt.executeQuery();
            
            while (rs.next()){
                aux+=rs.getString("nombre")+"|"+rs.getLong("parcial1")+"|"+rs.getLong("parcial2")+"|";
            }
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
        out.println(aux);
        out.close();
        out.flush();

        try {
            conn.close();
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
    }

    public void doPost(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException{
        //doGet(req,res);
    }
    
}